<?php get_header(); ?>
<div class="left_wrap col-md-9 col-sm-12 col-xs-12">
    <div class="row">
        <div class="left_content col-md-12 col-sm-12 col-xs-12">
            <?php include(TEMPLATEPATH.'/inc/breadcrumbs.php'); ?>
            <!-- END BREADCRUMB -->
            <div class="left_content_inner">

                <?php if (have_posts()) : ?>

                        <div class="row">
                            <?php
                                $count_total = get_option('posts_per_page ');
                                $categories = get_the_category();
                                foreach($categories as $category) {
                                    $cat_id = $category->cat_ID;
                                }
                                $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
                                query_posts("paged=$page&cat=".$cat_id);
                                $count = 0;
                                while (have_posts()) : the_post();
                            ?>
                            <?php if($count == 0 || $count == 1) { ?>
                            <?php include(TEMPLATEPATH.'/inc/archive_wrap_first.php')?>
                            <!-- END ARCHIVE WRAP 1 -->
                            <?php $count++; } else if($count == 2 || $count == 3 || $count == 4) {?>
                            <?php include(TEMPLATEPATH.'/inc/archive_wrap_second.php')?>
                            <!-- END ARCHIVE WRAP 2 -->
                            <?php  $count++; } else if($count == 5 || $count == 6) { ?>
                            <?php include(TEMPLATEPATH.'/inc/archive_wrap_third.php')?>
                            <!-- END ARCHIVE WRAP 3 -->
                            <?php $count++; } else if($count <= 9){ ?>
                            <?php include(TEMPLATEPATH.'/inc/archive_wrap_fouth.php')?>
                            <!-- END ARCHIVE WRAP 4 -->
                            <?php $count++; } ?>
                            <?php
                                endwhile;
                                wp_reset_query();
                            ?>
                            <?php  if($count == 1) { echo "</div></div></div>" ;?>
                            <?php } else if($count == 3) { echo "</div></div></div>";?>
                            <?php } else if($count == 4){ echo "</div></div></div>"; ?>
                            <?php } else if($count == 6) { echo "</div></div></div>" ;?>
                            <?php } else if($count == 8) { echo "</div></div></div>";?>
                            <?php } else if($count == 9){ echo "</div></div></div>"; }?>
                        </div><div class="archive_navi"><?php wp_pagenavi(); ?></div>

                <?php else : ?>

                    <h2>Nothing found</h2>

                <?php endif; ?>
                <!-- END SOCIAL -->
            </div><!-- END LEFT CONTENT INNER -->
        </div><!-- END LEFT CONTENT -->

    </div>
</div><!-- END LEFT WRAP -->

<?php get_sidebar(); ?>

<?php get_footer(); ?>